package bookpos.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import bookpos.dao.OrderItemDao;
import bookpos.dao.OrdersDao;
import bookpos.entity.OrderItem;
import bookpos.entity.Orders;
import bookpos.service.OrdersService;
import bookpos.vo.MonthLedger;
/**
 * 订单业务实现类
 * @author WZB
 *
 */
@Service
public class OrdersServiceImpl implements OrdersService {
	@Autowired
	private OrdersDao dao;


	public void save(Orders vo) {
		dao.save(vo);
		
	}
	public void update(Orders vo) {
		dao.update(vo);
		
	}
	public void delete(int id) {
		Orders vo = dao.get(id);
		dao.delete(vo);
	}

	public List<Orders> findAll(int page, int rows, String sort, String order) {
		return dao.findAll(page, rows, sort, order);
	}

	public int getTotal() {
		return dao.countAll();
	}
	public void saveOrders(String oid, String total) {
		Orders o = new Orders();
		o.setOid(oid);
		o.setTotal(Double.parseDouble(total));
		dao.save(o);
	}
	public List<MonthLedger> findMonthLedger() {
		
		return dao.findBySQLMonthLedger("select count(*) as number,sum(total) as total from bookpos_orders");
	}
	
}
